package cn.kimming.rpc.common.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ClassUtil {

    private static final Logger logger = LoggerFactory.getLogger(ClassUtil.class);

    public static Class[] parseNames2Classes(String[] classNames) {
        Class[] classes = new Class[classNames.length];
        try {
            for (int i = 0; i < classes.length; i++) {
                classes[i] = Class.forName(classNames[i]);
            }
        } catch (Exception e) {
            logger.error("[my-rpc] parse classes fail", e);
        }
       return classes;
    }

    public static String[] parseClasses2Names(Class[] classes) {
        String[] names = new String[classes.length];
        for (int i = 0; i < names.length; i++) {
            names[i] = classes[i].getCanonicalName();
        }
        return names;
    }
}
